<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

    <jsp:include page="${pageContext.request.contextPath}/WEB-INF/views/screen/admin/resource.jsp"/>
    <script type="text/javascript" charset="utf-8"
            src="${pageContext.request.contextPath}/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8"
            src="${pageContext.request.contextPath}/js/ueditor/ueditor.all.min.js"></script>
</head>

<body>
<div class="layui-collapse">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">新增|编辑</h2>
        <div class="layui-colla-content layui-show">
            <form class="layui-form layui-form-pane" action="">
                <input type="hidden" name="uuid" value="${data.uuid}"/>
                <%--<input type="hidden" id="contentNoTag" name="contentNoTag" value=""/>--%>
                <%--<input type="hidden" id="summary" name="summary" value=""/>--%>
                <input type="hidden" id="id" name="id" value="${data.id}"/>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">标题</label>
                        <div class="layui-input-inline">
                            <input type="text" name="title" lay-verify="required" placeholder="请输入博客标题" autocomplete="off"
                                   class="layui-input" value="${data.title}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">类型</label>
                        <div class="layui-input-inline">
                            <select name="blogTypeId" lay-verify="required" lay-search>
                                <option value="">请选择博客类型</option>
                                <c:forEach var="blogType" items="${blogTypeCountList }">
                                    <option value="${blogType.id }" <c:if
                                            test="${blogType.id ==data.blogTypeId}"> selected</c:if> >${blogType.typeName }</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">关键字</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" placeholder="请输入关键字" autocomplete="off"
                                   class="layui-input" value="${data.keyword}">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">文本域</label>
                    <div class="layui-input-block">
                        <script id="content" name="content" style="height:400px" type="text/plain"></script></div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <c:choose>
                            <c:when test="${type!='look'}">
                                <button  class="layui-btn" lay-submit lay-filter="save">提交</button>
                            </c:when>
                        </c:choose>
                        <a href="/admin/blog/index" class="layui-btn">返回</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


</body>
</html>
<script src="${pageContext.request.contextPath}/js/ux/blog/blog.js"></script>
<script>
    var ue = UE.getEditor('content');
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;

    UE.Editor.prototype.getActionUrl = function (action) {
    //判断路径   这里是config.json 中设置执行上传的action名称
        if (action == 'uploadimage') {
            return '/admin/blog/uploadImg';
        } else if (action == 'uploadvideo') {
            return '';
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }
    if ('${data.id}' != '') {
    $.post("/admin/blog/getContent", {},
    function (result) {
        if (result) {
            ue.ready(function () {
                ue.setContent(result.content);
            });
        }
    },
    "json");//这里返回的类型有：json,html,xml,text
    }
</script>


